#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
int main() {
	int a;
	int reversea;
	scanf("%d", &a);
	int ge, shi, bai, qian;
	ge = a % 10;
	shi = (a % 100)/10;
	bai = (a % 1000)/100;
	qian = a / 1000;
	reversea = ge * 1000 + shi * 100 + bai * 10 + qian;
	printf("%.4d", reversea);
	return 0;
}